package edu.auctionmart

import edu.auctionmart.Role

/**
 * User domain class.
 */
class User {
	static transients = ['pass']
	static hasMany = [authorities: Role]
	static belongsTo = Role

	/** Username */
	String username
	/** User Real Name*/
	String userRealName
	/** MD5 Password */
	String passwd
	/** enabled */
	boolean enabled

	String email
	boolean emailShow

	/** description */
	String description = ''

	/** plain password to create a MD5 password */
	String pass = '[secret]'
	
	Preferences preferences
	Profile profile

	static constraints = {
		username(size: 3..25, blank: false, unique: true)
		userRealName(nullable: false, blank: false)
		passwd(nullable: false, blank: false)
		email(nullable: false, blank: false)
		enabled()
		preferences(nullable: true)
		profile(nullable: true)
	}
	
	static mapping = {
		profile lazy: false
	}
	
	String toString() {
		"${username}"
	}
}
